/**
  ******************************************************************************
  * @file    
  * @author 
  * @version 
  * @date    
  * @brief   
  ******************************************************************************
	* @attention
  *
  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

#include "main.h"

static USART_InitTypeDef USART_InitStructure;

/**
  * @brief  Configures the USART.
  * @param  None
  * @retval None
  */
void USART_Config(void)
{
  /* Enable UART clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
	
  /* USARTx configured as follow:
        - BaudRate = 9600 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART2, &USART_InitStructure);
	
	/* Enable the Rx buffer not empty interrupt */
	USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
	
  /* Enable USART */
  USART_Cmd(USART2, ENABLE);
}

/**
  * @brief  Reinits the USART - will reconfigure the baud rate prescalers.
  * @param  None
  * @retval None
  */
void USART_UpdateSpeed(void)
{
	USART_Init(USART2, &USART_InitStructure);
}

/************************************** EOF *********************************/
